actions.js ➔ createActions   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 50

Duplication

Lines 50
Ratio 100 %

Importance

Changes 0
Metric Value
nc 1
nop 1
dl 50
loc 50
c 0
b 0
f 0
cc 1
rs 8.6363

1 Function

Rating   Name   Duplication   Size   Complexity  
B actions.js ➔ ... ➔ ??? 46 46 1
1 View Code Duplication
import axios from 'axios'
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
2
3
export function createActions(route) {
4
  return {
5
    LOAD_COUNTERS: ({ commit }) => {
6
      return new Promise(resolve => {
7
        axios
8
          .all([
9
            axios.get(route('admin.posts.draft.counter')),
10
            axios.get(route('admin.posts.pending.counter')),
11
            axios.get(route('admin.posts.published.counter')),
12
            axios.get(route('admin.users.active.counter')),
13
            axios.get(route('admin.form_submissions.counter'))
14
          ])
15
          .then(
16
            axios.spread(
17
              (
18
                newPostsCount,
19
                pendingPostsCount,
20
                publishedPostsCount,
21
                activeUsersCount,
22
                formSubmissionsCount
23
              ) => {
24
                commit('SET_COUNTER', {
25
                  type: 'newPostsCount',
26
                  counter: newPostsCount.data
27
                })
28
                commit('SET_COUNTER', {
29
                  type: 'pendingPostsCount',
30
                  counter: pendingPostsCount.data
31
                })
32
                commit('SET_COUNTER', {
33
                  type: 'publishedPostsCount',
34
                  counter: publishedPostsCount.data
35
                })
36
                commit('SET_COUNTER', {
37
                  type: 'activeUsersCount',
38
                  counter: activeUsersCount.data
39
                })
40
                commit('SET_COUNTER', {
41
                  type: 'formSubmissionsCount',
42
                  counter: formSubmissionsCount.data
43
                })
44
45
                resolve()
46
              }
47
            )
48
          )
49
      })
50
    }
51
  }
52
}
53